package com.tuantuan.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuantuan.dao.ClassrequireDao;
import com.tuantuan.model.Classrequire;
import com.tuantuan.service.ClassrequireService;

@Service("ClassrequireService")
@Transactional
public class ClassrequireServiceImpl implements ClassrequireService{

	@Resource(name="ClassrequireDao")
	private ClassrequireDao claRequire;
	@Override
	public String addClassrequire(Classrequire c) {
		// TODO Auto-generated method stub
		Classrequire classReq = claRequire.queryClassrequireByCode(c);
		if(classReq == null ){
			claRequire.addClassrequire(c);
			return "succ";
		}
		return "fail";
	}

	@Override
	public String deleteClassrequire(int classId) {
		// TODO Auto-generated method stub
		Classrequire c = new Classrequire();
		c.setClassId(classId);
		Classrequire classReq = claRequire.queryClassrequireById(c);
		if(classReq != null){
			claRequire.deleteClassrequire(classReq);
			return "succ";
		}
		return "fail";
	}

	@Override
	public String updateClassrequire(Classrequire c) {
		// TODO Auto-generated method stub
		Classrequire classReq = claRequire.queryClassrequireByCode(c);
		if(classReq == null){
			claRequire.updateClassrequire(c);
			return "succ";
		}
		return "fail";
	}

	public ClassrequireDao getClaRequire() {
		return claRequire;
	}

	public void setClaRequire(ClassrequireDao claRequire) {
		this.claRequire = claRequire;
	}
	

	
}
